<?php
class PerModel extends BaseModel
{
	/**
	 *
	 * @param int $uid
	 * @param string $fields
	 * @author Ice <iceinto@mallog.com.cn>
	 */
	public function getByUid($uid, $fields = 'mid'){
		$map = array();
		$map['uid'] = $uid;
		return $this->getByWhere($map, $fields);
	}

	/**
	 *
	 * @param int $uid
	 * @param int $mid
	 * @author Ice <iceinto@mallog.com.cn>
	 */
	public function setUserMall($uid, $mid) {
		$rs = $this->query ( 'DELETE FROM `m_per` WHERE ( uid = ' . $uid . ' )' );
		$data ['uid'] = $uid;
		$data ['mid'] = $mid;
		return $this->add ( $data );
	}

	public function getUserMall($uid){
		$map = array ();
		$map['uid'] = $uid;
		return  $this->where($map)->select();
	}
	
	/**
	 * Set user per
	 * @param int $uid
	 * @param array $data
	 * @author Ice <iceinto@mallog.com.cn>
	 */
	public function setUserPer($uid, $data) {
		$rs = $this->query ( 'DELETE FROM `m_per` WHERE ( uid = ' . $uid . ' )' );
		return $this->add($data);
	}
}